package com.hzlj.position.dbsync.liaoning.job;

import com.fz.common.redis.annotation.SyncLock;
import com.hzlj.position.dbsync.liaoning.service.MessageSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 同步消息读取时间
 */
@Slf4j
@Component
public class MessageReadSyncJob {
    @Resource
    private MessageSyncService messageSyncService;

    /**
     * 每5分钟一次
     */
    @SyncLock(lockMs = 60000)
    @Scheduled(cron = "${job.message.read.sync:0 1/5 * * * ?}")
    public void updateNeverReport() {
        long start = System.currentTimeMillis();
        log.info("任务开始执行[同步消息服务]");
        long size = messageSyncService.sync();
        log.info("任务结束执行[同步消息服务],cost={},size={}", System.currentTimeMillis() - start, size);
    }
}
